Skip to main content

Step 1: ApplyFabricToken

In order to establish communication with the SuperApp API fabric, you must first get a fabric token. For this purpose, you need to apply for a fabric token using the applyFabricToken service.

  • API\service\applyFabricTokenService.js

Create apply token service​

Create a file at API\service\applyFabricTokenService.js:

API\service\applyFabricTokenService.js
const https = require("http");
const config = require("../config/config");
var request = require("request");

function applyFabricToken() {
return new Promise((resolve, reject) => {
var options = {
method: "POST",
url: config.baseUrl + "/payment/v1/token",
headers: {
"Content-Type": "application/json",
"X-APP-Key": config.fabricAppId,
},
rejectUnauthorized: false, //add when working with https sites
requestCert: false, //add when working with https sites
agent: false, //add when working with https sites
body: JSON.stringify({
appSecret: config.appSecret,
}),
};
console.log(options);
request(options, function (error, response) {
let result = JSON.parse(response.body);
resolve(result);
});
});
}

module.exports = applyFabricToken;

Request Parameters​

HEADER PARAMETERS​

ParameterData TypeM/ODescription
X-APP-KeyStringMFabric App ID, provided by fabric portal of Ethio telecom

REQUEST BODY SCHEMA​

ParameterData TypeM/ODescription
appSecretStringMApp Secret, provided by fabric portal of Ethio telecom

Response Parameters​

ParameterData TypeDescription
tokenStringApiFabric Token
effectiveDateStringEffective Date of App Token, the Format is yyyyMMddHHmmss
expirationDateStringExpiration Date of App Token, the Format is yyyyMMddHHmmss